﻿using EPOS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EPOS.Controllers
{
    public class HomeController : BaseController
    {
        //
        // GET: /Home/
        ePosDataContext ep = new ePosDataContext();
        public ActionResult Index()
        {
            if (Session["user"] == null)
            {
                ViewData["logindurum"] = "Üye Girişi";
                ViewData["yenikayit"] = "Şimdi Üye Olun";
            }
            else
            {
                ViewData["yenikayit"] = "Hoş Geldiniz";
                ViewData["logindurum"] = "Bana Özel";
            }

            ViewBag.slider = (from s in ep.sliders
                              where s.status == true
                              orderby s.sliderID
                              select s).ToList();
            ViewBag.banner = (from b in ep.banners
                              where b.status == true
                              orderby b.bannerID
                              select b).ToList();

            ViewBag.topproducts = ((from u in ep.urunlers
                                    where u.status == true
                                    orderby u.eklenmeTarih
                                    select u).Take(6)).ToList();


            return View();
        }

        public ActionResult Hakkimizda()
        {

            return View();
        }

        [HttpGet]
        public ActionResult Urunler()
        {
            ViewBag.Urunler = (from u in ep.urunlers
                               where u.status==true
                               select u).ToList();
            return View();
        }

        public ActionResult Bayilik()
        {

            return View();
        }

        public ActionResult Subelerimiz()
        {

            return View();
        }

        public ActionResult Iletisim()
        {

            return View();
        }

        public ActionResult Detaylar(int id)
        {
            ViewBag.productdetails = (from p in ep.urunlers
                                      where p.urunID == id && p.status == true
                                      select p).ToList();


            ViewBag.productsphotos = (from f in ep.urunresimleris
                                      where f.urunID == id && f.status == true
                                      select f).ToList();



            ViewBag.relatedproduct = (from r in ep.urunlers
                                      where new[] { 1, 2, 3 }.Contains(r.urunID)
                                      select r).ToList();

            return View();
        }

        public ActionResult tedarikci(int id)
        {
            ViewBag.tedarikciDetails = (from p in ep.tedarikcilers
                                      where p.tedarikciID == id && p.status == true
                                      select p).ToList();
           
            return View();
        }
        public ActionResult Sepet()
        {

            return View();
        }

        public ActionResult kSepet()
        {
            return View();
        }

        public ActionResult Kategoriler(string id)
        {
            if (id[0]=='S')
            {

                ViewBag.Urunler = (from u in ep.urunlers
                                   where u.altkategoriID == Convert.ToInt32(id.Substring(1))
                                   select u).ToList();
            }
            else
            {
                ViewBag.Urunler = (from u in ep.urunlers
                                   where u.kategoriID == Convert.ToInt32(id)
                                   select u).ToList();
            }
            return View();
        }

        public ActionResult Login()
        {

            return View();
        }

        public ActionResult delivery()
        {

            return View();
        }
        public ActionResult gizlilikPolitikası()
        {

            return View();
        }
        public ActionResult sartlarKosullar()
        {

            return View();
        }

        public ActionResult iadeler()
        {

            return View();
        }
        public ActionResult siteHaritasi()
        {

            return View();
        }
        public ActionResult markalar()
        {

            return View();
        }
        public ActionResult hediyeCekleri()
        {

            return View();
        }
        public ActionResult bizeKatilin()
        {

            return View();
        }
        public ActionResult ozelUrunler()
        {

            return View();
        }
        public ActionResult siparisGecmisi()
        {

            return View();
        }
        public ActionResult bulten()
        {

            return View();
        }
        public ActionResult hesabim()
        {

            return View();
        }
        public ActionResult istekOneriler()
        {

            return View();
        }

    }
}
